﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
 
 This code is provided on an AS IS basis, with no WARRANTIES,
  CONDITIONS or GUARANTEES of any kind.
-->
<UserControl x:Class="Peter.View.ViewFileExplorer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Logic"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:mvvm="clr-namespace:Peter.Common.Tree;assembly=Peter.Common"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             d:DataContext="{d:DesignInstance logic:ModelFileExplorer}">
   <Grid>
      <controls:Explorer ExecuteCommand="{Binding Path=ExecuteCommand}"
                         SelectedPath="{Binding Path=SelectedFilePath, Mode=TwoWay}"
                         SelectedTreeItem="{Binding Path=SelectedItem, Mode=TwoWay}">
         <controls:Explorer.ContextMenu>
            <ContextMenu ItemsSource="{Binding Path=ContextMenuItems}"
                         ItemContainerStyleSelector="{StaticResource _MenuItemStyleSelector}"/>
         </controls:Explorer.ContextMenu>

            <controls:Explorer.Resources>

                <DataTemplate DataType="{x:Type mvvm:ModelTreeViewItem}">
                    <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                        <icons:IconDisplay IconSize="Medium"
                                     Margin="0,0,3,0"
                                     Icon="{Binding Path=Icon}" />
                        <TextBlock Text="{Binding Path=Text}"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0" />
                    </StackPanel>
                </DataTemplate>

                <HierarchicalDataTemplate DataType="{x:Type controls:ExplorerItem}"
                                      ItemsSource="{Binding Path=Children}">
               <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                  <icons:IconDisplay IconSize="Medium"
                                     Margin="0,0,3,0"
                                     Icon="{Binding Path=Icon}" />
                  <TextBlock Text="{Binding Path=Text}"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0" />
               </StackPanel>
            </HierarchicalDataTemplate>

         </controls:Explorer.Resources>
      </controls:Explorer>
   </Grid>
</UserControl>
